/**
 * @Author：ming
 * @Date：2023/9/27 11:06 AM
 * @Filename：Lc122
 */

/**
 * @author ming
 */
public class Lc122 {
    public int maxProfit(int[] prices) {
        int max = 0;
        int profit = 0;
        int cost = prices[0];

        for (int i = 0; i < prices.length; i++) {
            if(prices[i]>cost ){
                profit = prices[i]-cost;
                max += profit;

            }
            cost = prices[i];
        }


        return max;
    }
}
